package com.ddwl.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Fu Zhaohui
 * @version 1.0.0
 * @date 2019/9/13 5:34
 */
public interface OrderEnum {

    /**
     * 订单类型
     */
    @AllArgsConstructor
    @Getter
    enum OrderType {
        MALL((byte) 0, "商场订单"),
        RECHARGE((byte) 1, "充值"),
        ;

        private Byte code;
        private String name;
    }

    /**
     * 订单类型
     */
    @AllArgsConstructor
    @Getter
    enum TradeStatus {
        P("待支付"),
        S("已支付"),
        C("已撤单"),
        R("已退款"),
        ;

        private String name;
    }

    /**
     * 售后状态
     */
    @AllArgsConstructor
    @Getter
    enum AfterStatus {
        CANCEL(0, "取消售后"),
        APPLY(1, "提交申请"),
        ACCEPT(2, "客服受理"),
        SEND(3, "寄回中"),
        RECEIVED(4, "官方收货"),
        REFUNDING(5, "退款中"),
        REFUNDED(6, "完成退款"),
        EXCHANGED(7, "完成换货"),
        REJECT(8, "已拒绝"),
        END(9, "售后订单超时关闭"),
        REFUNDFAIL(10, "退款失败"),
        UNAFTER(20, "未售后");

        private Integer code;
        private String name;

        // 根据code获取名称
        public static String getValueByCode(Integer code) {
            for (AfterStatus t : AfterStatus.values()) {
                if (t.getCode() == code)
                    return t.getName();
            }
            return null;
        }
    }

    /**
     * 申请类型
     */
    @AllArgsConstructor
    @Getter
    enum AfterType {
        RETURN(0, "退货退款"),
        REFUND(1, "仅退款"),
        EXCHANGE(2, "换货");

        private Integer code;
        private String name;

        // 根据code获取名称
        public static String getValueByCode(Integer code) {
            for (AfterType t : AfterType.values()) {
                if (t.getCode() == code)
                    return t.getName();
            }
            return null;
        }
    }

    /**
     * 退货原因
     */
    @AllArgsConstructor
    @Getter
    enum AfterReason {
        NOTLIKE(0, "不喜欢、效果不好"),
        WRONGSIZE(1, "商品描述的尺寸与实物不符"),
        WRONGGOODS(2, "卖家发错货"),
        WRONGPACKAGE(3, "包装/商品破损/污渍"),
        OTHER(4, "其他");
        private Integer code;
        private String name;

        // 根据code获取名称
        public static String getValueByCode(Integer code) {
            for (AfterReason t : AfterReason.values()) {
                if (t.getCode() == code)
                    return t.getName();
            }
            return null;
        }
    }

    /**
     * 地址订单状态
     */
    @AllArgsConstructor
    @Getter
    enum AddrOrderStatus {

        UN_SEND(0, "未发货"),
        SEND(1, "已发货"),
        SELF(2, "自提");

        private Integer code;
        private String name;

        /**
         * 根据name判断 是否是枚举中的一员
         *
         * @param name
         * @return
         */
        public static boolean isIncludeName(String name) {
            AddrOrderStatus t = getName(name);
            if (null == t) return false;
            return true;
        }

        public static AddrOrderStatus getName(String name) {
            for (AddrOrderStatus t : AddrOrderStatus.values()) {
                if (t.getName().equals(name))
                    return t;
            }
            return null;
        }

    }


    /**
     * erp调用接口
     */
    @AllArgsConstructor
    @Getter
    enum ThirdPartRecordService {

        ITEMLIST("goods/ddwlOpenApi/itemlist", "获取商品信息接口"),
        DELIVERY("order/ddwlOpenApi/delivery", "订单发货接口"),
        ORDERLIST("order/ddwlOpenApi/orderlist", "获取订单列表接口"),
        ORDERDETAIL("order/ddwlOpenApi/orderDetail（", "获取订单详情接口"),
        ;

        private String code;
        private String name;
    }


    /**
     * 支付方式
     */
    @AllArgsConstructor
    @Getter
    enum PayType {

        ONE(0, "一次性结清"),
        PHASE(1, "阶段付款"),
        WX(0, "微信"),
        ALI_PAY(1, "支付宝"),
        ;

        private Integer code;
        private String name;
    }

    /**
     * 支付方式
     */
    @AllArgsConstructor
    @Getter
    enum DeliveryType {

        KD(0, "快递"),
        WS(1, "外送"),
        ZT(2, "自提"),
        ;

        private Integer code;
        private String name;
    }

    @AllArgsConstructor
    @Getter
    enum DeliveryStatus {

        TACK(0, "商家已接单"),
        STOCK(10, "备货中"),
        STOCK_COMPLETE(20, "备货完成"),
        START_DELIVERY(30, "开始配送"),
        END_DELIVERY(40, "商品送达"),
        CONFIRM(50, "用户确认收货");

        private Integer code;
        private String name;
    }

    String WX_ORDER_BODY = "58度商城-购物消费";

    @AllArgsConstructor
    @Getter
    enum PayStatus {
        CRE(0, "创建"),
        PRE(10, "提交"),
        SUCCEED(20, "支付成功"),
        FILL(30, "失败"),
        ;
        private Integer code;
        private String name;
    }


    @AllArgsConstructor
    @Getter
    enum SettlementStatus {
        CRE(0, "未结算"),
        PRE(10, "结算中"),
        SUCCEED(20, "结算成功"),
        FILL(30, "结算失败"),
        ;
        private Integer code;
        private String name;
    }

    /**
     * 订单状态
     */
    @AllArgsConstructor
    @Getter
    enum OrderStatus {
        UN_PAY(0, "待支付"),
        PAYED(1, "已支付"),
        SEND(2, "已发货"),
        RECEIVED(3, "已签收"),
        CANCEL(4, "已取消"),
        REFUNDING(5, "退款中"),
        REFUND(6, "已退款"),
        CLOSE(7, "付款超时关闭"),
        ;

        private Integer code;
        private String name;
    }

    /**
     * 下单类型 (0普通订单 1秒杀单 2砍价单 3限时购 4打折)
     */
    @AllArgsConstructor
    @Getter
    enum OrderWay {
        NORMAL(0, "普通订单"),
        SEC_KILL(1, "秒杀单"),
        BARGAIN(2, "砍价单"),
        LIMIT_TIME(3, "限时购"),
        DISCOUNT(4, "打折"),
        REDUCTION(5, "满减券"),
        DEDUCTION(6, "抵扣券"),
        EXCHANGE(7, "兑换券"),
        ;

        private Integer code;
        private String name;
    }

}
